<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="viewport"
	content="width=device-width, maximum-scale=1.0, initial-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>盒子实验室 BOX LAB登录</title>
<link rel="stylesheet" href="/css/global.css">
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico?t=${.now?long}"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="keywords" content="盒子实验室 BOX LAB,论坛，社区">
<meta name="description" content="针对国内青少年STEAM创客教育建设的，提供教学案例，案例代码，国内外一手资源和创新实验信息等的开源交流社区。">
<link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/layui.css">
<link rel="stylesheet" href="/css/login.css">
<script src="/js/jquery-1.10.2.min.js"></script>
<script src="/layui.js"></script>
</head>
<body>
<!-- 菜单 -->
<div class="phone-menu-box">
	<div class="phone-nav">
		<ul>
			<li onclick="hideMenu();">
				<a><span class="close"></span><span>页面导航</span></a>
			</li>
			<li class="<#if subtype?? && subtype == 'index'>layui-this</#if>">
				<a class="" href="/">论坛首页</a>
			</li>
			<li class="<#if subtype?? && (subtype == 'topicIndex' || subtype == 'accept' || subtype == 'finsh' || subtype == 'essence')>layui-this</#if>">
				<a href="#" class="" onclick="searchHref('','','','topicIndex')">谈天说地</a>
			</li>
			<li class="<#if subtype?? && subtype == 'microcase' && typename == 'microcaseindex'>layui-this</#if>">
				<a class="" href="/microcase/allList">下载中心</a>
			</li>
			<li class="">
				<a target="_blank" href="https://store.myboxlab.com/f">商城<span></span></a>
			</li>
		</ul>
	</div>
</div>
<div class="" id="modal" onclick="hideMenu();"></div>
<div class="phone-head">
	<div class="phone-menu" onclick="showMenu();"></div>
	<div class="phone-logo">
		<span class="logo-icon"></span>
		<span class="logo-text">盒子实验室</span>
	</div>
	<div class="phone-user">
		<#if user??>
			<a href="/user/index.html"><img class="user-head-img layui-circle" src="/${user.fileurl!''}" onerror="this.src='/images/user/default.jpg';this.onerror=null"></a>
		<#else>
			<a href="/reg.html">注册</a>
			<a href="/login.html">&nbsp;|&nbsp;登录</a>
		</#if>
	</div>
</div>
<div class="back-bar pc-display-none">
 	<a href="window.location.href=document.referrer" ><i class="fa fa-angle-left"></i></a>
 	<span>登录</span>
 	<a href="/reg.html">注册</a>
</div>
	<div class="login-box">
		<div class="login-logo">
			<a href="/"> <img src="/images/boxlab.png">
			</a>
		</div>
		<!-- /.login-logo -->
		<div class="login-box-body">
			<p class="login-box-msg">盒子实验室 BOX LAB账号登录</p>
			
			<form id="loginForm" action="/login.html"
				class="loginFormWrapper layui-form" method="post">
				<#if referer??>
				<input type="hidden" name="referer" value="${referer!''}"/>
				</#if>
				<div class="form-group has-feedback login">
					<span class="pc-display-none mobile-text">昵称</span>
					<input  id="username" name="username" 
						class="form-control" required lay-verify="required|usernameIs"   placeholder="昵称/手机号" autofocus>
				</div>
				<div class="form-group has-feedback login" style="margin-bottom:20px;">
					<span class="pc-display-none mobile-text">密码</span>
					<input  name="password"  type="password"
						class="form-control" required lay-verify="required"   placeholder="请在此输入密码">
				</div>
				<!-- 验证码 -->
				<div class="form-group has-feedback code login" style="margin-bottom: 20px;">
					<span class="pc-display-none mobile-text">验证码</span>
					<input class="form-control" type="text" name="smsCode" id="code" placeholder="验证码" required lay-verify="required|codeValid"  >
					<!-- -->
			        <img id="img" src=""/>
			        <a onclick="checkCode()" >刷新</a>
				</div>
				<div class="form-group has-feedback">
					<button class="button-add" lay-submit  lay-filter="formDemo">登录</button>
				</div>
				<!-- <div class="row">
					<div class="col-md-6">
						<div class="checkbox">
							<label> <input type="checkbox" name="sla" value="1"
								checked="checked">七天内自动登录
							</label>
						</div>
					</div>
				</div> -->
			</form>
		</div>
		<div class="login-reg">
			<a class="forget" href="/forget.html">忘记密码？</a>	
			<span class="reg-span">还没有账号，去<a class="reg" href="/reg.html">注册</a></span>
			
		</div>
		<!-- /.login-box-body -->
	</div>
	<footer class="mobile-display-none">
		<span>Copyright©2018  版权所有 上海垤诗教育科技有限公司</span>
		<a target="_blank" href="http://www.miibeian.gov.cn/">沪ICP备18006983号-2</a>
	</footer>
</body>
<script language="javascript">
	
var mobileTopicSign="pc"	//帖子判断移动端分页数量
    function browserRedirect() {//手机端设置html的font-size
        var sUserAgent = navigator.userAgent.toLowerCase();
        var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
        var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
        var bIsMidp = sUserAgent.match(/midp/i) == "midp";
        var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
        var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
        var bIsAndroid = sUserAgent.match(/android/i) == "android";
        var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
        var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
        if (bIsIpad|| bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
            console.log("phone");
            mobileTopicSign = "phone";
            ! function(e, t) {
    			function i() {
    				var t = n.getBoundingClientRect().width / 10;
    				n.style.fontSize = t + "px", p.rem = e.rem = t
    			}
    			var a, r = e.document,
    				n = r.documentElement,
    				o = r.querySelector('meta[name="viewport"]'),
    				l = r.querySelector('meta[name="flexible"]'),
    				m = r.querySelector('meta[name="flexible-in-x5"]'),
    				s = !0,
    				d = 0,
    				c = 0,
    				p = t.flexible || (t.flexible = {});
    			if(o) {
    				console.warn("将根据已有的meta标签来设置缩放比例");
    				var u = o.getAttribute("content").match(/initial\-scale=([\d\.]+)/);
    				u && (c = parseFloat(u[1]), d = parseInt(1 / c))
    			} else if(l) {
    				var f = l.getAttribute("content");
    				if(f) {
    					var h = f.match(/initial\-dpr=([\d\.]+)/),
    						v = f.match(/maximum\-dpr=([\d\.]+)/);
    					h && (d = parseFloat(h[1]), c = parseFloat((1 / d).toFixed(2))), v && (d = parseFloat(v[1]), c = parseFloat((1 / d).toFixed(2)))
    				}
    			}
    			if(m && (s = "false" !== m.getAttribute("content")), !d && !c) {
    				var x = (e.navigator.appVersion.match(/android/gi), e.chrome),
    					g = e.navigator.appVersion.match(/iphone/gi),
    					b = e.devicePixelRatio,
    					w = /TBS\/\d+/.test(e.navigator.userAgent),
    					y = !1;
    				try {
    					y = "true" === localStorage.getItem("IN_FLEXIBLE_WHITE_LIST")
    				} catch(e) {
    					y = !1
    				}
    				c = 1 / (d = g || x || w && s && y ? b >= 3 && (!d || d >= 3) ? 3 : b >= 2 && (!d || d >= 2) ? 2 : 1 : 1)
    			}
    			if(n.setAttribute("data-dpr", d), !o)
    				if((o = r.createElement("meta")).setAttribute("name", "viewport"), o.setAttribute("content", "initial-scale=" + c + ", maximum-scale=" + c + ", minimum-scale=" + c + ", user-scalable=no"), n.firstElementChild) n.firstElementChild.appendChild(o);
    				else {
    					var E = r.createElement("div");
    					E.appendChild(o), r.write(E.innerHTML)
    				}
    			e.addEventListener("resize", function() {
    				clearTimeout(a), a = setTimeout(i, 300)
    			}, !1), e.addEventListener("pageshow", function(e) {
    				e.persisted && (clearTimeout(a), a = setTimeout(i, 300))
    			}, !1), "complete" === r.readyState ? r.body.style.fontSize = 12 * d + "px" : r.addEventListener("DOMContentLoaded", function(e) {
    				r.body.style.fontSize = 12 * d + "px"
    			}, !1), i(), p.dpr = e.dpr = d, p.refreshRem = i, p.rem2px = function(e) {
    				var t = parseFloat(e) * this.rem;
    				return "string" == typeof e && e.match(/rem$/) && (t += "px"), t
    			}, p.px2rem = function(e) {
    				var t = parseFloat(e) / this.rem;
    				return "string" == typeof e && e.match(/px$/) && (t += "rem"), t
    			}
    		}(window, window.lib || (window.lib = {}));
        }
    }
    browserRedirect();
	if((window.frameElement && window.frameElement.id || '') != ""){
		top.location.href = "/login.html" ;
	}
	layui.use(['form', 'layer'], function(){
	  var layer = layui.layer;
	  var form = layui.form();
	  form.render(); //更新全部
	  <#if msg == "0">
		if(${msg == "0"}){
			layer.msg('密码错误!', {icon: 2}); 
		}
		console.log(${msg})
	</#if>
	  
	  form.verify({
		  usernameIs: function(value, item){
			  var number = /^[0-9]*$/;
			  var message = "";
			  if(number.test($("#username").val())){
				  $.ajax({
					  type:"POST",
					  url:"/checkoutUser",
					  data: {parm: $("#username").val(),flag:3},
					  async: false,
					  success:function(data){
							if(data.mobile != "1"){
								message = "用户名不存在！";
							}
					  }
				  })
			  }else{
				  $.ajax({
					  type:"POST",
					  url:"/checkoutUser",
					  data: {parm: $("#username").val(),flag:1},
					  async: false,
					  success:function(data){
							if(data.username != "1"){
								message = "用户名不存在！";
							}
					  }
				  })
			  }
			  if(message!=""){
			      return message;
			   }
		  },
		  codeValid: function(value, item){
			  var message = "";
			  $.ajax({
				  type:"POST",
				  url:"/checkCode",
				  async: false,
				  data: {verCode: value},
				  success:function(data){
					  if(data == "error"){
						  checkCode();
						  message = '验证码输入有误！';
					  }
				  }
			  })
			  if(message!==""){
			      return message;
			    }
		  }
		 
		});
	  //提交
	  form.on('submit(formDemo)', function(data){
	  }); 
	});
	
	$(document).ready(function() {
		checkCode();
		$(".close-box").click(function(){
			$("#shadeDiv").html("");
			$(".login-reg-cover").addClass("layui-hide");
		})
	});
	
	function checkCode(){
		$.ajax({
			  type:"POST",
			  url:"/authImage",
			  contentType: "application/x-www-form-urlencoded; charset=utf-8",  
			  success:function(data){
					$("#img").attr("src","/res/authImage/" +data +".html") 
			  }
		  })
	}
	function showMenu(){
		console.log("打开menu");
		$(".phone-menu-box").removeClass("phone-menu-box-hide");
		$(".phone-menu-box").addClass("phone-menu-box-show");
		$("#modal").addClass("modal");
		$("html,body").css({"overflow":"hidden","height":"100%"});
	}
	function hideMenu(){
		console.log("关闭menu");
		$(".phone-menu-box").removeClass("phone-menu-box-show");
		$(".phone-menu-box").addClass("phone-menu-box-hide");
		$("#modal").removeClass("modal");
		$("html,body").css({"overflow":"inherit","height":"100%"});
	}
</script>
</html>